home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / DJGPP / CBGRX103.ZIP / contrib / libgrx / src / phfillp.c < prev    next >
Text File  |  1993-12-06  |  3KB  |  98 lines

  1. /**
  2.  ** PHFILLP.C
  3.  **
  4.  **  Copyright (C) 1992, Csaba Biegl
  5.  **    820 Stirrup Dr, Nashville, TN, 37221
  6.  **    csaba@vuse.vanderbilt.edu
  7.  **
  8.  **  This file is distributed under the terms listed in the document
  9.  **  "copying.cb", available from the author at the address above.
  10.  **  A copy of "copying.cb" should accompany this file; if not, a copy
  11.  **  should be available from where this file was obtained.  This file
  12.  **  may not be distributed without a verbatim copy of "copying.cb".
  13.  **  You should also have received a copy of the GNU General Public
  14.  **  License along with this program (it is in the file "copying");
  15.  **  if not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  16.  **  Cambridge, MA 02139, USA.
  17.  **
  18.  **  This program is distributed in the hope that it will be useful,
  19.  **  but WITHOUT ANY WARRANTY; without even the implied warranty of
  20.  **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21.  **  GNU General Public License for more details.
  22.  **/
  23.  
  24. #include "p16.h"
  25. #include "memcopy.h"
  26. #include "worddraw.h"
  27.  
  28. #define FGONLY  1
  29.  
  30. void _GrPHFillPattern(int x,int y,int width,GrPattern *p)
  31. {
  32.     pixptr dst;
  33.  
  34.     if(width <= 0) return;
  35.     x += CURC->gc_xoffset;
  36.     y += CURC->gc_yoffset;
  37.     dst = (pixptr)(CURC->gc_baseaddr + (y * CURC->gc_lineoffset) + (x << 1));
  38.     _ClrDir();
  39.     if(p->gp_ispixmap) {
  40.         int pattwdt = p->gp_pxp_width;
  41.         int optype  = C_OPER(p->gp_pxp_oper);
  42.         int cpysize = x % pattwdt;
  43.         pixptr srcline = (pixptr)(p->gp_pxp_source.gc_baseaddr +
  44.          ((y % p->gp_pxp_height) * p->gp_pxp_source.gc_lineoffset));
  45.         pixptr srcptr = srcline + cpysize;
  46.  
  47.         cpysize = pattwdt - cpysize;
  48.         _SaveDS();
  49.         while(width > 0) {
  50.         if(cpysize > width) cpysize = width;
  51.         switch(optype) {
  52.             case C_XOR: _RowCpyXorW(X,dst,srcptr,cpysize); break;
  53.             case C_OR:  _RowCpyOrW(O,dst,srcptr,cpysize);  break;
  54.             case C_AND: _RowCpyAndW(A,dst,srcptr,cpysize); break;
  55.             default:    _RowCpyW(C,dst,srcptr,cpysize);       break;
  56.         }
  57.         width  -= cpysize;
  58.         dst    += cpysize;
  59.         srcptr  = srcline;
  60.         cpysize = pattwdt;
  61.         }
  62.         _RestoreDS();
  63.     }
  64.     else {
  65.         int bits = p->gp_bmp_data[y % p->gp_bmp_height];
  66.         int fgc  = p->gp_bmp_fgcolor;
  67.         int bgc  = p->gp_bmp_bgcolor;
  68.         int fgop = C_OPER(fgc);
  69.         int bgop = C_OPER(bgc);
  70.         int drawfg = _GrPHDrawTable[fgop] ^ (fgc &= C_SIGNIF);
  71.         int drawbg = _GrPHDrawTable[bgop] ^ (bgc &= C_SIGNIF);
  72.  
  73.         x &= 7;
  74.         bits = (bits << x) | ((bits & 0xff) >> (8 - x));
  75.         if(drawfg && drawbg && (fgop == bgop)) {
  76.         switch(fgop) {
  77.             case C_XOR: _PatternXor(dst,bits,width,fgc,bgc); return;
  78.             case C_OR:  _PatternOr(dst,bits,width,fgc,bgc);  return;
  79.             case C_AND: _PatternAnd(dst,bits,width,fgc,bgc); return;
  80.             default:    _PatternSet(dst,bits,width,fgc,bgc); return;
  81.         }
  82.         }
  83.         if(drawfg) switch(fgop) {
  84.         case C_XOR: _PattFGCXor(dst,bits,width,fgc); break;
  85.         case C_OR:  _PattFGCOr(dst,bits,width,fgc);  break;
  86.         case C_AND: _PattFGCAnd(dst,bits,width,fgc); break;
  87.         default:    _PattFGCSet(dst,bits,width,fgc); break;
  88.         }
  89.         if(drawbg) switch(bgop) {
  90.         case C_XOR: _PattBGCXor(dst,bits,width,bgc); break;
  91.         case C_OR:  _PattBGCOr(dst,bits,width,bgc);  break;
  92.         case C_AND: _PattBGCAnd(dst,bits,width,bgc); break;
  93.         default:    _PattBGCSet(dst,bits,width,bgc); break;
  94.         }
  95.     }
  96. }
  97.  
  98.